﻿Public Class Micro : Implements InterfaceTransfer
    Private Const URL As String = "https://api.microsofttranslator.com/V2/Ajax.svc/Translate"
    Private Const APP_ID As String = "A4D660A48A6A97CCA791C34935E4C02BBB1BEC1C"
    Public Function trans(q As String, from_code As String, to_code As String) As String Implements InterfaceTransfer.trans
        Try
            Dim helper As New HttpHelp
            Dim par As String
            Dim r As String = ""
            par = "appId=" & APP_ID & "&from=" & from_code & "&to=" & to_code & "&text=" & System.Web.HttpUtility.UrlEncode(q, Text.Encoding.UTF8)
            Dim result As String = Trim(helper.AllGETHttpRequest(URL, par))
            If result.Length > 3 Then
                r = Strings.Mid(result, 1, result.Length - 2)
            End If
            Return r
        Catch ex As Exception
            Return ex.Message
        End Try
    End Function
End Class
